package com.diaohaiwen.framework.mq.rocket;

import com.diaohaiwen.framework.mq.rocket.attrbute.*;
import com.diaohaiwen.framework.mq.rocket.constant.RocketHeaderConst;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.Objects;

/**
 * @author 刁海文
 * @since 2024/1/27 21:54
 */
@EnableRocket
@Component
public class Test {

    /**
     * {@link EnableRocket} 启用
     * {@link RocketLister} 方法级注解，仅支持在 {@link Component}下使用 ，支持多topic,tags，对于同一个 Topic、不同Tags可以在不同的方法修饰，默认为 *
     * {@link RocketHeader} msg 的属性，固定属性请参考 {@link RocketHeaderConst}
     * {@link RocketHeaders} 获取全部的自定义属性，value 等于true时包含固定属性，如Topic、tag等，attribute为空时表示全部
     * {@link RocketSendTo} 将返回值转发至其他的 Topic队列
     */
    @RocketLister(topics = "TestTopic", tags = {"TagA", "TabB"})
    @RocketSendTo(topics = "TestGroup1", tags = "Tags")
    public String test1(@RocketBody Map<String, Objects> body, @RocketHeader(RocketHeaderConst.topic) String topic, @RocketHeaders(value = true) Map<String, Objects> headers) {
        System.out.println(body);
        System.out.println(topic);
        System.out.println(headers);

        return "success";
    }

    @RocketLister(topics = "TestTopic", tags = "TagC")
    public void test2(@RocketBody String body) {

    }

}
